import pytest
from appium.webdriver import Remote
from selenium.webdriver.support.wait import WebDriverWait
from appium.webdriver.common.mobileby import MobileBy as by
from selenium.webdriver.support import expected_conditions as ec
from appium.webdriver.common.touch_action import TouchAction

@pytest.fixture(scope="session")
def driver():
    caps = {
        "platformName": "Android",
        "appium:platformVersion": "9.0.0",
        "appium:deviceName": "emulator-5554",
        "appium:appPackage": "com.zhao.myreader",
        "appActivity": "com.zhao.myreader.ui.home.MainActivity"
    }
    url = "http://127.0.0.1:4723/wd/hub"
    # 打开app

    driver = Remote(url, caps)
    wait = WebDriverWait(driver, 3)

    yield driver, wait
    driver.quit()

@pytest.fixture()
def By():
    return by

@pytest.fixture()
def EC():
    return ec

@pytest.fixture()
def touchAction():
    return TouchAction

